﻿using IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Web.IBLL;
using Web.Model;

namespace Web.BLL
{
    public class RNumBLL:IRNumBLL
    {
        public RNumBLL(IBaseDAL<RoomNumClass> dAL)
        {
            DAL = dAL;
        }

        public IBaseDAL<RoomNumClass> DAL { get; }

        public Task<int> RNAdd(RoomNumClass n)
        {
            return DAL.AddAsync(n);
        }

        public dynamic RShow(int Pageindex, int Pagesize)
        {
            var data = DAL.GetAll();
            var c = data.Count();
            var d = data.OrderBy(x => x.Id).Skip((Pageindex - 1) * Pagesize).Take(Pagesize).ToList();
            return new
            {
                count = c,
                list  =d 
            };
        }

        public List<RoomNumClass> RNShow()
        {
            return DAL.GetAll().ToList();
        }
    }
}
